package com.example.xm.ui.home.fragments;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.xm.R;
import com.example.xm.adapter.HomeAdapter.HomeSquareAdapter;
import com.example.xm.base.BaseFragment;
import com.example.xm.bean.HomeBean.HomeArticleBean;
import com.example.xm.bean.HomeBean.HomeBannderBean;
import com.example.xm.bean.HomeBean.HomeHotUserBean;
import com.example.xm.bean.HomeBean.HomePhotoBean;
import com.example.xm.bean.HomeBean.HomeRecommendBean;
import com.example.xm.bean.HomeBean.HomeRewardBean;
import com.example.xm.bean.HomeBean.HomeSquareBean;
import com.example.xm.bean.HomeBean.HomeTopicDiscussedBean;
import com.example.xm.bean.HomeBean.HomeVideoBean;
import com.example.xm.interfaces.home.IHome;
import com.example.xm.presenter.home.RecommendPresenter;

import java.util.ArrayList;

import butterknife.BindView;

public class Fragment_Square extends BaseFragment<IHome.RecommendPersenter> implements IHome.RecommendView {

    @BindView(R.id.tv_tab_all)
    TextView tvTabAll;
    @BindView(R.id.tv_tab_fujin)
    TextView tvTabFujin;
    @BindView(R.id.tv_tab_miaoyin)
    TextView tvTabMiaoyin;
    @BindView(R.id.v)
    View v;
    @BindView(R.id.rlv_square)
    RecyclerView rlvSquare;
    private ArrayList<HomeSquareBean.DataBean.DynamicsBean> list;
    private HomeSquareAdapter homeSquareAdapter;


    @Override
    protected IHome.RecommendPersenter initPresenter() {
        return new RecommendPresenter();
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_square;
    }

    @Override
    protected void initView() {
        list = new ArrayList<>();
        rlvSquare.setLayoutManager(new LinearLayoutManager(getActivity()));
        rlvSquare.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayout.VERTICAL));
        homeSquareAdapter = new HomeSquareAdapter(getActivity(), list);
        rlvSquare.setAdapter(homeSquareAdapter);
    }

    @Override
    protected void initData() {
        mPresenter.getSquare();
    }

    @Override
    protected void initListener() {

    }

    @Override
    public void showTips(String tips) {

    }

    @Override
    public void showLoading(int visble) {

    }

    @Override
    public void getBannerReturn(HomeBannderBean result) {

    }

    @Override
    public void getTopicDiscussedReturn(HomeTopicDiscussedBean result) {

    }

    @Override
    public void getRecommendReturn(HomeRecommendBean result) {

    }

    @Override
    public void getHotUserReturn(HomeHotUserBean result) {

    }

    @Override
    public void getSquareReturn(HomeSquareBean result) {
        if (result.getStatus().getStatusCode() == 100){
            list.addAll(result.getData().getDynamics());
            homeSquareAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void getVideoReturn(HomeVideoBean result) {

    }

    @Override
    public void getPhotoReturn(HomePhotoBean result) {

    }

    @Override
    public void getHomeArticleReturn(HomeArticleBean result) {

    }

    @Override
    public void getHomeRewardReturn(HomeRewardBean result) {

    }
}
